/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * crear_editar_usuario.java
 *
 * Created on 24/09/2011, 10:51:35 AM
 */
package Usuario;

import bufete.IngresarUsuario;
import callProcs.ProcsUsuario;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
 *
 * @author josema
 */
public class crear_editar_usuario extends javax.swing.JFrame {
    
    String NombreNivel;
    public ProcsUsuario tipouser = new ProcsUsuario();
    java.sql.ResultSet rs=null;
    IngresarUsuario user = new IngresarUsuario();
    /** Creates new form crear_editar_usuario */
    public crear_editar_usuario(int op) {
        initComponents();
        rb_si_est.setSelected(false);
        rb_no_est.setSelected(true);
        rb_si_casos.setSelected(false);
        rb_no_casos.setSelected(true);
        rb_si_cliente.setSelected(false);
        rb_no_cliente.setSelected(true);
        rb_si_ases.setSelected(false);
        rb_no_ases.setSelected(true);
        rb_si_asig.setSelected(false);
        rb_no_asig.setSelected(true);
        rb_si_usuario.setSelected(false);
        rb_no_usuario.setSelected(true);
        
        if(op==1){
            b_editar.setVisible(true);
            b_crear.setVisible(false);
            jTextField1.setEditable(false);
        }
        else{
            b_editar.setVisible(false);
            b_crear.setVisible(true);
            jTextField1.setEditable(true);
        }
        
        
    }

    
    public void verResultsetObtenerDatosTU(java.sql.ResultSet rs ,String Nnivel){
        
        try {
            //IdCliente = Integer.parseInt(idCliente);
            NombreNivel= Nnivel;
            jTextField1.setText(NombreNivel);
            while(rs.next()){
                        
//                        idcli = rs.getString("c.idCliente");
                        
                        //JOptionPane.showMessageDialog(null,Nnivel);
                        if(rs.getObject("PR.Modulo").toString().equals("Cliente"))
                          {
                        rb_si_cliente.setSelected(true);
                        rb_no_cliente.setSelected(false);
                          } 
                        if(rs.getObject("PR.Modulo").toString().equals("Estudiante"))
                          {
                        rb_si_est.setSelected(true);
                        rb_no_est.setSelected(false);
                          } 
                        if(rs.getObject("PR.Modulo").toString().equals("Asesor"))
                          {
                        rb_si_ases.setSelected(true);
                        rb_no_ases.setSelected(false);
                          } 
                        if(rs.getObject("PR.Modulo").toString().equals("Asignaciones"))
                          {
                        rb_si_asig.setSelected(true);
                        rb_no_asig.setSelected(false);
                          } 
                        if(rs.getObject("PR.Modulo").toString().equals("Usuario"))
                          {
                        rb_si_usuario.setSelected(true);
                        rb_no_usuario.setSelected(false);
                          } 
                         if(rs.getObject("PR.Modulo").toString().equals("Casos"))
                          {
                        rb_si_casos.setSelected(true);
                        rb_no_casos.setSelected(false);
                          } 
                        
            }
              
           // this.IdCliente= idCliente;
        } catch (SQLException ex) {
            Logger.getLogger(crear_editar_usuario.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        rb_si_est = new javax.swing.JRadioButton();
        rb_no_est = new javax.swing.JRadioButton();
        jLabel5 = new javax.swing.JLabel();
        rb_no_cliente = new javax.swing.JRadioButton();
        rb_si_cliente = new javax.swing.JRadioButton();
        jLabel6 = new javax.swing.JLabel();
        rb_no_casos = new javax.swing.JRadioButton();
        rb_si_casos = new javax.swing.JRadioButton();
        jLabel7 = new javax.swing.JLabel();
        rb_no_ases = new javax.swing.JRadioButton();
        rb_si_ases = new javax.swing.JRadioButton();
        jLabel8 = new javax.swing.JLabel();
        rb_no_asig = new javax.swing.JRadioButton();
        rb_si_asig = new javax.swing.JRadioButton();
        jLabel9 = new javax.swing.JLabel();
        rb_no_usuario = new javax.swing.JRadioButton();
        rb_si_usuario = new javax.swing.JRadioButton();
        jLabel10 = new javax.swing.JLabel();
        b_crear = new javax.swing.JButton();
        b_editar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(bufete.BufeteApp.class).getContext().getResourceMap(crear_editar_usuario.class);
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jTextField1.setText(resourceMap.getString("jTextField1.text")); // NOI18N
        jTextField1.setName("jTextField1"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        rb_si_est.setText(resourceMap.getString("rb_si_est.text")); // NOI18N
        rb_si_est.setName("rb_si_est"); // NOI18N
        rb_si_est.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rb_si_estActionPerformed(evt);
            }
        });

        rb_no_est.setText(resourceMap.getString("rb_no_est.text")); // NOI18N
        rb_no_est.setName("rb_no_est"); // NOI18N
        rb_no_est.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rb_no_estActionPerformed(evt);
            }
        });

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        rb_no_cliente.setText(resourceMap.getString("rb_no_cliente.text")); // NOI18N
        rb_no_cliente.setName("rb_no_cliente"); // NOI18N
        rb_no_cliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rb_no_clienteActionPerformed(evt);
            }
        });

        rb_si_cliente.setText(resourceMap.getString("rb_si_cliente.text")); // NOI18N
        rb_si_cliente.setName("rb_si_cliente"); // NOI18N
        rb_si_cliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rb_si_clienteActionPerformed(evt);
            }
        });

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        rb_no_casos.setText(resourceMap.getString("rb_no_casos.text")); // NOI18N
        rb_no_casos.setName("rb_no_casos"); // NOI18N
        rb_no_casos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rb_no_casosActionPerformed(evt);
            }
        });

        rb_si_casos.setText(resourceMap.getString("rb_si_casos.text")); // NOI18N
        rb_si_casos.setName("rb_si_casos"); // NOI18N
        rb_si_casos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rb_si_casosActionPerformed(evt);
            }
        });

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        rb_no_ases.setText(resourceMap.getString("rb_no_ases.text")); // NOI18N
        rb_no_ases.setName("rb_no_ases"); // NOI18N
        rb_no_ases.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rb_no_asesActionPerformed(evt);
            }
        });

        rb_si_ases.setText(resourceMap.getString("rb_si_ases.text")); // NOI18N
        rb_si_ases.setName("rb_si_ases"); // NOI18N
        rb_si_ases.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rb_si_asesActionPerformed(evt);
            }
        });

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        rb_no_asig.setText(resourceMap.getString("rb_no_asig.text")); // NOI18N
        rb_no_asig.setName("rb_no_asig"); // NOI18N
        rb_no_asig.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rb_no_asigActionPerformed(evt);
            }
        });

        rb_si_asig.setText(resourceMap.getString("rb_si_asig.text")); // NOI18N
        rb_si_asig.setName("rb_si_asig"); // NOI18N
        rb_si_asig.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rb_si_asigActionPerformed(evt);
            }
        });

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        rb_no_usuario.setText(resourceMap.getString("rb_no_usuario.text")); // NOI18N
        rb_no_usuario.setName("rb_no_usuario"); // NOI18N
        rb_no_usuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rb_no_usuarioActionPerformed(evt);
            }
        });

        rb_si_usuario.setText(resourceMap.getString("rb_si_usuario.text")); // NOI18N
        rb_si_usuario.setName("rb_si_usuario"); // NOI18N
        rb_si_usuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rb_si_usuarioActionPerformed(evt);
            }
        });

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        b_crear.setText(resourceMap.getString("b_crear.text")); // NOI18N
        b_crear.setName("b_crear"); // NOI18N
        b_crear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                b_crearActionPerformed(evt);
            }
        });

        b_editar.setText(resourceMap.getString("b_editar.text")); // NOI18N
        b_editar.setName("b_editar"); // NOI18N
        b_editar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                b_editarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(40, 40, 40)
                .addComponent(jLabel2)
                .addGap(36, 36, 36)
                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(229, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(192, Short.MAX_VALUE)
                .addComponent(jLabel3)
                .addGap(21, 21, 21))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 356, Short.MAX_VALUE)
                .addComponent(rb_si_est)
                .addGap(58, 58, 58)
                .addComponent(rb_no_est)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(485, Short.MAX_VALUE)
                .addComponent(jLabel4)
                .addGap(47, 47, 47))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 380, Short.MAX_VALUE)
                .addComponent(rb_si_cliente)
                .addGap(58, 58, 58)
                .addComponent(rb_no_cliente)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 385, Short.MAX_VALUE)
                .addComponent(rb_si_casos)
                .addGap(58, 58, 58)
                .addComponent(rb_no_casos)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 365, Short.MAX_VALUE)
                .addComponent(rb_si_ases)
                .addGap(58, 58, 58)
                .addComponent(rb_no_ases)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 340, Short.MAX_VALUE)
                .addComponent(rb_si_asig)
                .addGap(58, 58, 58)
                .addComponent(rb_no_asig)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 375, Short.MAX_VALUE)
                .addComponent(rb_si_usuario)
                .addGap(58, 58, 58)
                .addComponent(rb_no_usuario)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(342, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addGap(129, 129, 129))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(390, Short.MAX_VALUE)
                .addComponent(b_crear)
                .addGap(56, 56, 56)
                .addComponent(b_editar)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(41, 41, 41)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(36, 36, 36)
                .addComponent(jLabel3)
                .addGap(24, 24, 24)
                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rb_no_est)
                    .addComponent(rb_si_est)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rb_no_cliente)
                    .addComponent(rb_si_cliente)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rb_no_casos)
                    .addComponent(rb_si_casos)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rb_no_ases)
                    .addComponent(rb_si_ases)
                    .addComponent(jLabel8))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rb_no_asig)
                    .addComponent(rb_si_asig)
                    .addComponent(jLabel9))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rb_no_usuario)
                    .addComponent(rb_si_usuario)
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 32, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(b_editar)
                    .addComponent(b_crear))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void b_editarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_editarActionPerformed
        // TODO add your handling code here:
        
        String NomNivel="";
        NomNivel=jTextField1.getText();
      
                String NTipoUser="";
        NTipoUser=jTextField1.getText();
        
        //---------------------botones de SI--------------------------
        if (rb_si_est.isSelected() ){
            
            try {
                rs=tipouser.VerificaModulos(NTipoUser, "Estudiante");
                while(rs.next()){
                                
                if(rs.getInt("count(Privilegios_Modulo)")==0){
                    tipouser.InsertaModulosTipoUser(NTipoUser, "Estudiante");
                }
                }
            } catch (SQLException ex) {
                Logger.getLogger(crear_editar_usuario.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        
        if (rb_si_ases.isSelected() ){
            try {
                rs=tipouser.VerificaModulos(NTipoUser, "Asesor");
                while(rs.next()){
                                
                if(rs.getInt("count(Privilegios_Modulo)")==0){
                    tipouser.InsertaModulosTipoUser(NTipoUser, "Asesor");
                }
                }
                
            } catch (SQLException ex) {
                Logger.getLogger(crear_editar_usuario.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        if (rb_si_asig.isSelected() ){
            try {
                rs=tipouser.VerificaModulos(NTipoUser, "Asignaciones");
                while(rs.next()){
                
                    if(rs.getInt("count(Privilegios_Modulo)")==0){
                    tipouser.InsertaModulosTipoUser(NTipoUser, "Asignaciones");
                }
                }
            } catch (SQLException ex) {
                Logger.getLogger(crear_editar_usuario.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        if (rb_si_casos.isSelected() ){
            try {
                rs=tipouser.VerificaModulos(NTipoUser, "Casos");
                while(rs.next()){
                
                
                if(rs.getInt("count(Privilegios_Modulo)")==0){
                    tipouser.InsertaModulosTipoUser(NTipoUser, "Casos");
                }
                }
            } catch (SQLException ex) {
                Logger.getLogger(crear_editar_usuario.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        if (rb_si_cliente.isSelected() ){
            try {
                rs=tipouser.VerificaModulos(NTipoUser, "Cliente");
                while(rs.next()){
                
                if(rs.getInt("count(Privilegios_Modulo)")==0){
                    tipouser.InsertaModulosTipoUser(NTipoUser, "Cliente");
                }
                }
            } catch (SQLException ex) {
                Logger.getLogger(crear_editar_usuario.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        if (rb_si_usuario.isSelected() ){
            try {
                rs=tipouser.VerificaModulos(NTipoUser, "Usuario");
                while(rs.next()){
                
                if(rs.getInt("count(Privilegios_Modulo)")==0){
                    tipouser.InsertaModulosTipoUser(NTipoUser, "Usuario");
                }
                }
            } catch (SQLException ex) {
                Logger.getLogger(crear_editar_usuario.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        
        
        //---------------------botones de NO--------------------------
        if (rb_no_est.isSelected() ){
            try {
                rs=tipouser.VerificaModulos(NTipoUser, "Estudiante");
                while(rs.next()){
                
                
                if(rs.getInt("count(Privilegios_Modulo)")>0){
                    tipouser.EliminarModulosTipoUser(NTipoUser, "Estudiante");
                }
                }
            } catch (SQLException ex) {
                Logger.getLogger(crear_editar_usuario.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        
        if (rb_no_ases.isSelected() ){
            try {
                rs=tipouser.VerificaModulos(NTipoUser, "Asesor");
                while(rs.next()){
                
                
                if(rs.getInt("count(Privilegios_Modulo)")>0){
                    tipouser.EliminarModulosTipoUser(NTipoUser, "Asesor");
                }
                }
            } catch (SQLException ex) {
                Logger.getLogger(crear_editar_usuario.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        if (rb_no_asig.isSelected() ){
            try {
                rs=tipouser.VerificaModulos(NTipoUser, "Asignaciones");
                while(rs.next()){
                
                
                if(rs.getInt("count(Privilegios_Modulo)")>0){
                    tipouser.EliminarModulosTipoUser(NTipoUser, "Asignaciones");
                }
                }
            } catch (SQLException ex) {
                Logger.getLogger(crear_editar_usuario.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        if (rb_no_casos.isSelected() ){
            try {
                rs=tipouser.VerificaModulos(NTipoUser, "Casos");
                while(rs.next()){
                
                
                if(rs.getInt("count(Privilegios_Modulo)")>0){
                    tipouser.EliminarModulosTipoUser(NTipoUser, "Casos");
                }
                }
            } catch (SQLException ex) {
                Logger.getLogger(crear_editar_usuario.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        if (rb_no_cliente.isSelected() ){
            try {
                rs=tipouser.VerificaModulos(NTipoUser, "Cliente");
                while(rs.next()){
                
                if(rs.getInt("count(Privilegios_Modulo)")>0){
                    tipouser.EliminarModulosTipoUser(NTipoUser, "Cliente");
                }
                }
            } catch (SQLException ex) {
                Logger.getLogger(crear_editar_usuario.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        if (rb_no_usuario.isSelected() ){
            try {
                rs=tipouser.VerificaModulos(NTipoUser, "Usuario");
                while(rs.next()){
                
                if(rs.getInt("count(Privilegios_Modulo)")>0){
                    tipouser.EliminarModulosTipoUser(NTipoUser, "Usuario");
                }
                }
            } catch (SQLException ex) {
                Logger.getLogger(crear_editar_usuario.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        JOptionPane.showMessageDialog(null, "Tipo de Usuario editado con exito");
                
    }//GEN-LAST:event_b_editarActionPerformed

    private void b_crearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_crearActionPerformed
        // TODO add your handling code here:
        
        String NTipoUser=jTextField1.getText();
        try {
            tipouser.InsertaTipoUser(NTipoUser);
        } catch (SQLException ex) {
            Logger.getLogger(crear_editar_usuario.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        if (rb_si_est.isSelected() ){
            try {
                tipouser.InsertaModulosTipoUser(NTipoUser, "Estudiante");
            } catch (SQLException ex) {
                Logger.getLogger(crear_editar_usuario.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        
        if (rb_si_ases.isSelected() ){
            try {
                tipouser.InsertaModulosTipoUser(NTipoUser, "Asesor");
            } catch (SQLException ex) {
                Logger.getLogger(crear_editar_usuario.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        if (rb_si_asig.isSelected() ){
            try {
                tipouser.InsertaModulosTipoUser(NTipoUser, "Asignaciones");
            } catch (SQLException ex) {
                Logger.getLogger(crear_editar_usuario.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        if (rb_si_casos.isSelected() ){
            try {
                tipouser.InsertaModulosTipoUser(NTipoUser, "Casos");
            } catch (SQLException ex) {
                Logger.getLogger(crear_editar_usuario.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        if (rb_si_cliente.isSelected() ){
            try {
                tipouser.InsertaModulosTipoUser(NTipoUser, "Cliente");
            } catch (SQLException ex) {
                Logger.getLogger(crear_editar_usuario.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        if (rb_si_usuario.isSelected() ){
            try {
                tipouser.InsertaModulosTipoUser(NTipoUser, "Usuario");
            } catch (SQLException ex) {
                Logger.getLogger(crear_editar_usuario.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        user.llenarComboboxTipoUsuario();
        JOptionPane.showMessageDialog(null, "Tipo de Usuario creado exitosamente");
        this.dispose();
        
        
    }//GEN-LAST:event_b_crearActionPerformed

    private void rb_si_estActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rb_si_estActionPerformed
        // TODO add your handling code here:
        rb_no_est.setSelected(false);
    }//GEN-LAST:event_rb_si_estActionPerformed

    private void rb_no_estActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rb_no_estActionPerformed
        // TODO add your handling code here:
        rb_si_est.setSelected(false);
    }//GEN-LAST:event_rb_no_estActionPerformed

    private void rb_si_clienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rb_si_clienteActionPerformed
        // TODO add your handling code here:
        rb_no_cliente.setSelected(false);
    }//GEN-LAST:event_rb_si_clienteActionPerformed

    private void rb_no_clienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rb_no_clienteActionPerformed
        // TODO add your handling code here:
        rb_si_cliente.setSelected(false);
    }//GEN-LAST:event_rb_no_clienteActionPerformed

    private void rb_si_casosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rb_si_casosActionPerformed
        // TODO add your handling code here:
        rb_no_casos.setSelected(false);
    }//GEN-LAST:event_rb_si_casosActionPerformed

    private void rb_no_casosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rb_no_casosActionPerformed
        // TODO add your handling code here:
        rb_si_casos.setSelected(false);
    }//GEN-LAST:event_rb_no_casosActionPerformed

    private void rb_si_asesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rb_si_asesActionPerformed
        // TODO add your handling code here:
        rb_no_ases.setSelected(false);
    }//GEN-LAST:event_rb_si_asesActionPerformed

    private void rb_no_asesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rb_no_asesActionPerformed
        // TODO add your handling code here:
        rb_si_ases.setSelected(false);
    }//GEN-LAST:event_rb_no_asesActionPerformed

    private void rb_si_asigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rb_si_asigActionPerformed
        // TODO add your handling code here:
        rb_no_asig.setSelected(false);
    }//GEN-LAST:event_rb_si_asigActionPerformed

    private void rb_no_asigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rb_no_asigActionPerformed
        // TODO add your handling code here:
        rb_si_asig.setSelected(false);
    }//GEN-LAST:event_rb_no_asigActionPerformed

    private void rb_si_usuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rb_si_usuarioActionPerformed
        // TODO add your handling code here:
        rb_no_usuario.setSelected(false);
    }//GEN-LAST:event_rb_si_usuarioActionPerformed

    private void rb_no_usuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rb_no_usuarioActionPerformed
        // TODO add your handling code here:
        rb_si_usuario.setSelected(false);
    }//GEN-LAST:event_rb_no_usuarioActionPerformed

    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                //new crear_editar_usuario().setVisible(true);
                JFrame.setDefaultLookAndFeelDecorated(true);
                new crear_editar_usuario(0).setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton b_crear;
    private javax.swing.JButton b_editar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JRadioButton rb_no_ases;
    private javax.swing.JRadioButton rb_no_asig;
    private javax.swing.JRadioButton rb_no_casos;
    private javax.swing.JRadioButton rb_no_cliente;
    private javax.swing.JRadioButton rb_no_est;
    private javax.swing.JRadioButton rb_no_usuario;
    private javax.swing.JRadioButton rb_si_ases;
    private javax.swing.JRadioButton rb_si_asig;
    private javax.swing.JRadioButton rb_si_casos;
    private javax.swing.JRadioButton rb_si_cliente;
    private javax.swing.JRadioButton rb_si_est;
    private javax.swing.JRadioButton rb_si_usuario;
    // End of variables declaration//GEN-END:variables
}
